#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int cmp_int(void* e1, void* e2)
{
	return *(int*)e1 - *(int*)e2;
}
void Swap(void* p1, void* p2, int size)
{
	for (int i = 0; i < size;i++)
	{
		char temp = 0;
		temp = *((char*)p1 + i);
		*((char*)p1 + i) = *((char*)p2 + i);
		*((char*)p2 + i) = temp;
	}
}
void bubble(void* base, int count, int size, int (*p)(void*, void*))
{
	int i = 0; 
	int j = 0;
	for (i = 0; i < count-1; i++)
	{
		for (j = 0; j < count - 1 - i; j++)
		{
			if (*((char*)base + j * size) > *((char*)base + (j + 1) * size))
			{
				Swap((char*)base + j * size, (char*)base + (j + 1) * size,size);
			}
		}
	}

}
int main()
{
	int arr[10] = { 3,1,7,9,0,5,2,4,6,8 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	bubble(arr, sz, sizeof(arr[0]), cmp_int);
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}